﻿using System;
using System.Reflection;
using NHibernate.Mapping.ByCode;

namespace HYCodeBase.SqlUtility.ORMSuit
{
	internal class UseEntityModelInspector : ExplicitlyDeclaredModel
	{
		public override bool IsOneToMany(MemberInfo member)
		{
			PropertyAttribute propertyAttribute = member.GetCustomAttribute(typeof(PropertyAttribute)) as PropertyAttribute;
			return ((propertyAttribute == null || !propertyAttribute.IfIsManyToMany) && this.IsBag(member)) || base.IsOneToMany(member);
		}

		public override bool IsManyToManyItem(MemberInfo member)
		{
			PropertyAttribute propertyAttribute = member.GetCustomAttribute(typeof(PropertyAttribute)) as PropertyAttribute;
			return (propertyAttribute != null && propertyAttribute.IfIsManyToMany && this.IsBag(member)) || base.IsManyToManyItem(member);
		}
	}
}
